<template>
  <view>
    <CommonNavbar />
    <view class="h-12rpx" />
    <CommonSwiper :banner-list="bannerList" />
    <view class="h-30rpx" />
    <Enterprise v-if="clientType === 'enterprise'" />
    <Customer v-if="clientType === 'customer'" />
    <up-gap height="200rpx" />
  </view>
</template>

<script setup lang="ts">
import CommonNavbar from './components/v-navbar.vue';
import CommonSwiper from './components/v-swiper.vue';
import Enterprise from '@/pages/tab/home/enterprise.vue';
import Customer from '@/pages/tab/home/customer.vue';
import { commonConfigCli } from '@/api/common';
import { useUserStore } from '@/store';
import { userBanner } from '@/api/user';

const clientType  = uni.getStorageSync('clientType');

// const title = ref<string>('首页');
// title.value = import.meta.env.VITE_APP_TITLE;

const getConfig = async () => {
  const result = await commonConfigCli();
  console.log('result', result);
};

onLoad(() => {
  getConfig();
  getBanner(1);
});

onShow(() => {
  const { globalData } = getApp();
  globalData!.initTabbar(uni.$u.pages(), 0);
});
const bannerList:any = reactive([]);
async function getBanner(type:number) { //1首页
  let result = await userBanner({
    type: type
  });
  console.log('banner结果:::', result)
  for (let i = 0; i < result.length; i++) {
    const r = result[i]
    bannerList.push(r.image)
  }
}
</script>
